<layout name="page" />
<block name="content">
	{:widget('page_header/adv_search',array('name'=>'公司管理'))}
	<div id="adv_search" class="hidden">
		<form method="post" name="form_adv_search" id="form_adv_search">
			<div id="adv_search_header" class="row" style="">
				<h1 style="">高级搜索</h1>
				<i class="x1" class=""></i>
				<a class="btn btn-normal" id="submit_adv_search">搜索</a>
				<a class="btn btn-return" id="close_adv_search">关闭</a>
			</div>
			<div class="row" id="adv_search_body" >
				<div class="box col-6">
					<label class=" input-label" for="li_name">公司名：</label>
					<input  class="input" type="text" id="li_name" name="li_name" >
				</div>
				<div class="box col-6">
					<label class=" input-label" for="li_contacts">负责人：</label>
					<input  class="input" type="text" id="li_contacts" name="li_contacts" >
				</div>
			</div>
		</form>
	</div>
	<div class="operate-panel">
		<if condition="$auth->admin">
			<a class="btn btn-del" onclick="del();">删除</a>
		</if>
		<i class="x1"></i>
		<a class="btn btn-normal" onclick="add()"> 新建 </a>
		<if condition="$auth->admin">
			<a class="btn btn-normal" onclick="import_data();"> 导入 </a>
		</if>		
	</div>
	<div class="tab-box" id="select_letter">
		<div class="tab-header">
			<a>全部 </a>
			<a> A </a>
			<a> B </a>
			<a> C </a>
			<a> D </a>
			<a> E </a>
			<a> F </a>
			<a> G </a>
			<a> H </a>
			<a> I </a>
			<a> J </a>
			<a> K </a>
			<a> L </a>
			<a> M </a>
			<a> N </a>
			<a> O </a>
			<a> P </a>
			<a> Q </a>
			<a> R </a>
			<a> S </a>
			<a> T </a>
			<a> U </a>
			<a> V </a>
			<a> W </a>
			<a> X </a>
			<a> Y </a>
			<a> Z </a>
			<a> # </a>
		</div>
	</div>
	<div class="sub">
		<form id="form_data" name="form_data" method='post'>
			<div class="table">
				<ul>
					<li class="thead">
						<if condition="$auth->admin">
							<span class="w3"><label class="checkbox">
									<input  type="checkbox"class="toggle-select-all" data="id[]"/>
									<i class="icon"></i> </label> </span>
						</if>
						<span class="w10 x1">公司名</span>
						<span class="w8">负责人</span>
						<span class="w12 x1">公司网站</span>
						<span class="w10 x1">地址</span>
						<span class="w8">创建人</span>
						<span class="w12">创建时间</span>
					</li>
					<if condition="empty($list)">
						<li class="no-data">
							没找到数据
						</li>
						<else/>
						<foreach name="list" val="vo">
							<li class="tbody" letter="{$vo.letter}">
								<if condition="$auth->admin">
									<span class="w3"><label class="checkbox">
											<input type="checkbox" name="id[]" value="{$vo.id}" />
											<i class="icon"></i></label></span>
								</if>
								<span class="w10 x1"><a href="{:url('edit','id='.$vo['id'])}">{$vo.name}</a></span>
								<span class="w8">{$vo.contacts}</span>
								<span class="w12 x1">{$vo.website}</span>
								<span class="w10 x1">{$vo.address}</span>
								<span class="w8">{$vo.user_name}</span>
								<span class="w12">{:to_date($vo['create_time'],'Y-m-d')}</span>
							</li>
						</foreach>
					</if>
				</ul>
			</div>
		</form>
		<if condition="!empty($list)">
			{$page}
		</if>
	</div>

</block>
<block name="js">
	<script type="text/javascript">
		layui.use(['global'], function() {
			var $ = layui.jquery;
			set_return_url(null);
			var fn = {
				add : function() {
					window.open("{:url('add')}", '_self');
				},
				del : function() {
					if ($("input[name='id[]']:checked").length == 0) {
						layer.msg('请选择要删除的项目');
						return false;
					}
					//信息框-例2
					layer.msg('确定要删除吗?', {
						time : 0,
						btn : ['确定', '取消'],
						yes : function(index) {
							var vars = $("#form_data").serialize();
							send_ajax("{:url('del')}", vars, function(ret) {
								if (ret.status) {
									layer.msg(ret.info, function() {
										location.reload(true);
									});
								}
							});
						},
						no : function(index) {
							layer.close(index);
						}
					});
				},
				import_data : function() {
					window.open("{:url('import_data')}", '_self');
				}
			};

			win_exp(fn);

			$('#select_letter a').on('click', function() {
				var search_letter = trim(this.innerText);
				$('#select_letter a').removeClass('active');
				$(this).addClass('active');
				if (search_letter == '全部') {
					$('#form_data li.tbody').show();
				} else {
					$('#form_data li.tbody').hide();
					$('#form_data li.tbody').each(function() {
						var key = $(this).attr('letter').substr(0, 1);
						if (search_letter == key) {
							$(this).show();
						}
					});
				}
			});
		});

	</script>
</block>
